/**
 * related to repayRecord.ui
 * 
 * @Author : 2037630@163.com
 * @Timestamp : 2017-04-19
 */
var notify = sm("do_Notification");
var Controller = require("core/controller");
var log = require("util/log")
var net = require('util/net');
var server = require('config/server');
var repayRecord=ui('repayRecord')
var filter = require('util/filter')
var common=require("util")
Controller({
//	配置头部信息
	config:{
		name : 'repayRecord',
		header:{
			title:"我的回款"
		}
	},
	mapping : {
		"repayRecord" : "repayData",
		"repayBg.bgImage":"bg"
	},
	data : {
		repayData:[],
		bg:""
	},
	ui:{
		repayRecord:"repayRecord",
		repayBg: "repayBg"
	},
	methods : {
//		无数据时载入空白页
		goBlank:function(){
			if(this.data.repayData.length==0){
				this.ui.repayBg.bgImage="source://image/app/blank.png"
//				this.ui.repayRecord.visible=false
			}
			else{
				this.ui.repayBg.bgImage=""
//				this.ui.repayRecord.visible=true
			}
			this.refresh('$')
		},
//	获取回款记录信息
		getRepayList:function(){
			return net.send({
				server : server.organization.repayMoney,
				success : function(data) {
//					绑定用户数据并更新
					var list = data.map(function(x) {
						x.cupoStatus =filter.typeCodeConvert(x.cupoStatus),
						x.payaStyle =filter.typeCodeConvert(x.payaStyle),
						x.cupoPaynum=x.cupoPaynum.toFixed(2)
						return x
					})
					this.data.repayData=list;
					log.info("99999")
					log.info(this.data.repayData)
//					this.goBlank();
					this.refresh('repayRecord')
				},
				error : function(data) {
					this.goBlank();
					notify.toast(data.reason)
				},
				scope:this
			})
		}
	},
	loaded:function(){
		this.loadReady([this.getRepayList()])
	}
})

